{layout name="layout" /}
<div class="row ">
    <div class="col-sm-12 col-md-4 col-md-offset-4 m-t-lg p-t-xs">
        <form class="form-horizontal"  action="{:url('');}"  method="post">
            <div class="form-group row">
                <label for="input_phone" class="col-sm-3 control-label p-b-3">手机/邮箱</label>
                <div class="col-sm-9">
                    <input name="phone" type="phone" class="form-control" id="input_phone" placeholder="手机/邮箱">
                </div>
            </div>
            <div class="form-group row">
                <label for="input_password" class="col-sm-3 control-label p-b-3">密码</label>
                <div class="col-sm-9">
                    <input name="password" type="password" class="form-control" id="input_password" placeholder="密码">
                </div>
            </div>
            <div class="form-group row dsp-nn" id="captcha_div">
                <div class="col-sm-9 col-sm-offset-3"><img id="captcha" src="{:url('member/captcha')}" alt="captcha"  />
                </div>
                <label for="input_captcha" class="col-sm-3 control-label m-t-xs p-b-3">验证码</label>
                <div class="col-sm-9" style="">
                    <input name="captcha"  type="captcha" class="form-control" id="input_captcha" placeholder="验证码">
                </div>
            </div>
            <div class="form-group row">
                <div class="col-sm-offset-3 col-sm-9">
                    <div class="checkbox">
                        <label>
                            <input type="checkbox" name="keep"> 保持登陆状态
                        </label>
                    </div>
                </div>
            </div>
            <div class="form-group row">
                <div class="col-sm-offset-2 col-sm-9">
                    <button id="submit" type="submit" class="btn btn-primary" style="width: 100%">登陆</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script>
    $ (function ()
    {
        $(".header-title").html('登陆');
        $ ("#captcha").on ('click', function ()
        {
            let img_src = $ (this).attr ('src') + "?seed=" + Math.random;
            $ (this).attr ('src', img_src);
        });

        $ ("#submit").on ('click', function (eve)
        {
            eve.preventDefault ();
            let url = $ ('form').attr ('action');
            let data = $ ('form').serialize ();
            $.post (url, data, function (res)
            {
                $ ("#captcha").click ();
                if (res.captcha)
                {
                    $("#captcha_div").removeClass('dsp-nn');
                }

                if (res.code)
                {
                    layer_tips(res.msg,function() {
                       location.href = "{:merge_url('plan/plan_list');}";
                    });
                }
                else
                {
                    layer_tips(res.msg);
                }
            });
        });
    });

</script>